//
//  ZMBaseViewController.swift
//  ZMWeiboSwift
//
//  Created by pg on 2017/7/22.
//  Copyright © 2017年 pg. All rights reserved.
//

import UIKit

class ZMBaseViewController: UITableViewController {

    var isLogin: Bool = ZMUserAccountViewModel.sharedViewModel.islogin
    var visitorView : ZMVisitorView?
    
    override func loadView() {
        
        if isLogin {
            super.loadView()
        }else{
            visitorView = ZMVisitorView()
            view = visitorView
            setupNav()
        }
    }
   override func viewDidLoad() {
        super.viewDidLoad()

        visitorView?.visitorViewBtnClickCallBack = {(sender: UIButton) in
        
            //进入登录界面
            self.EnterLoagin()
       }
        
    }

    //MARK:- 初始化导航控制器
    func setupNav(){
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: #selector(loginButtonClick))
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: #selector(registButtonClick))
        
    }
    
    //登录按钮单击事件
    func loginButtonClick(){
        //进入登录界面
        EnterLoagin()
    }
    //注册按钮单击事件
    func registButtonClick(){
        //进入登录界面
        EnterLoagin()
    }
    
    func EnterLoagin(){
        print("登录....")
        //跳转到登录界面
        let visitorView = ZMOAuthViewController()
        let nav = ZMNavController(rootViewController: visitorView)
        self.present(nav, animated: true, completion: nil)
        
    }
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}
